package org.polaris.authority.service.impl;

import org.polaris.authority.domain.Menu;
import org.polaris.authority.dto.SetMenusDTO;
import org.polaris.authority.mapper.MenuMapper;
import org.polaris.authority.service.IMenuService;
import org.polaris.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
@Primary
public class MenuServiceImpl extends BaseServiceImpl<Menu> implements IMenuService {
    @Autowired
    private MenuMapper menuMapper;


    @Override
    public List<Menu> getMenuTree(Long eId) {
        return menuMapper.getMenuTree(eId);
    }

    @Override
    public List<Long> getMenus(Long eId) {
        return menuMapper.getMenus(eId);
    }

    @Override
    public void saveMenus(SetMenusDTO dto) {
        menuMapper.deleteAllById(dto.getEid());
        menuMapper.saveMenus(dto.getEid(),dto.getMenusId());
    }

}
